<?php

declare(strict_types=1);
/**
 * This file is part of habo_new_media.
 *
 * @link     https://www.berlen.cn/
 * @contact  tech@berlen.cn
 * @license  http://gitlab.rehou.cn/habo/habo_new_media/-/blob/master/README.md
 */
namespace app\service\analysis\data\material;

use app\enum\AnalysisEnum;
use app\service\analysis\data\material\pic\PicAreaMonthStatService;
use app\service\analysis\data\material\video\VideoAreaMonthStatService;
use app\service\BaseService;

final class MaterialAreaMonthStatService extends BaseService
{
    public function __construct()
    {
    }

    /**
     * 执行脚本.
     */
    public function runTask(array $arr = []): bool
    {
        if (! $arr) {
            return self::setError('未知素材月区域汇总数据');
        }

        if (isset($arr[2]) && $arr[2] == AnalysisEnum::TASK_TYPE_VIDEO) {
            return (new VideoAreaMonthStatService($arr))->setStat();
        }
        if (isset($arr[2]) && $arr[2] == AnalysisEnum::TASK_TYPE_PICTURE) {
            return (new PicAreaMonthStatService($arr))->setStat();
        }
        return self::setError('未知素材类型');
    }
}
